import './assets/main.css'

import { createApp } from 'vue'

import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import DkUI from '@vipl520/dk-ui'
import Vue3DraggableResizable from 'vue3-draggable-resizable'
import Vant from 'vant'
import Components from '@/components'
import DiyComponents from '@/diy/components'
// 2. 引入组件样式
import 'vant/lib/index.css'
import mitt from 'mitt'
import { directives } from '@/utils/directives'
import '@/utils/permission'
import 'animate.css/animate.min.css'
// 样式
import 'virtual:uno.css'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/display.css'
import '@vipl520/dk-ui/lib/index.scss'
import { setupStore } from '@/stores'
import { getToken, updateGlobalConfig } from '@/utils/auth'

// console.log('import.meta.env', import.meta.env.DEV)
const app = createApp(App)
updateGlobalConfig()
app.use(router)
app.use(ElementPlus, { locale: zhCn })
console.log(import.meta.env)

app.use(Vant)
app.use(Components)
app.use(DiyComponents)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.component('Vue3DraggableResizable', Vue3DraggableResizable)
app.config.globalProperties.eventBus = mitt()
directives(app)
setupStore(app)
app.use(DkUI, {
  AccessToken: getToken(),
  ApiUrl: import.meta.env.VITE_BASE_URL, // 默认的 API 地址
  Plaid: window.dkSys.plaid, // 平台ID
  Appid: window.dkSys.appid,
  AddonName: window.dkSys.addon_name,
  ProjectType: 'addon'
})
app.mount('#app')
